package intranet.client;

/**
 * @author Robin TROADEC
 */
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.VerticalPanel;

public class AdminTab extends VerticalPanel
{
	
	protected MenuBar	menu;
	protected Command	cmdUser, cmdCourse, cmdSubject;
	protected MenuItem	menuUser,menuCourse, menuSubject;
	protected VerticalPanel centerPanel;
	protected Session sess;
	protected AdminSubject adminSubject;
	protected AdminCourse adminCourse;
	protected AdminUser adminUser;
	
	
	/**
	 * Creation d'un panel d'administration regroupant les users,matières et filières
	 * @param s
	 */
	public AdminTab(Session s)
	{
		sess=s;
		createMenuBar();
		this.add(menu);
		
		centerPanel = new VerticalPanel();
		centerPanel.add(new AdminUser(sess));
		this.add(centerPanel);
	}
	
	//Creation de la menubar
	public void createMenuBar()
	{
        //création du menu pour chgt de fonction
        menu = new MenuBar(false);
        menu.setAutoOpen(false);
        menu.setWidth("100%");
        menu.setAnimationEnabled(true);
        
        
        //Commande executé par le menu Utilisateur
        cmdUser = new Command()
		{
			public void execute()
			{
				centerPanel.clear();
				adminUser = new AdminUser(sess);
				centerPanel.add(adminUser);
				
			}
		};
		 //Commande executé par le menu Matiere
		cmdSubject = new Command()
		{
			public void execute()
			{	
				centerPanel.clear();
				adminSubject = new AdminSubject(sess);
				centerPanel.add(adminSubject);
				
			}
		};
		 //Commande executé par le menu Filiere
		cmdCourse = new Command()
		{
			public void execute()
			{
				centerPanel.clear();
				adminCourse = new AdminCourse(sess);
				centerPanel.add(adminCourse);
			}
		};
		 
        menuUser = menu.addItem("Utilisateurs", cmdUser);
        menuCourse = menu.addItem("Filières", cmdCourse);
        menuSubject = menu.addItem("Matières", cmdSubject);
          
	}

	/**
	 * Fonction de redimensionnement
	 */
		public void onResize()
		{
			adminCourse.onResize();
			adminSubject.onResize();
			adminUser.onResize();
			
		}


}
